
// 获取位置
export const invitation = {
	data() {
		return {
			avatarUrl: '',
			hidden: true,
		}
	},
	methods: {
		getSkey() {
			let that = this
			// 查看是否授权
			let skey = uni.getStorageSync('session')
			console.log('skey', skey)
			if (skey) {
				uni.getSetting({
					success(setRes) {
						if (setRes.authSetting['scope.userInfo'] && uni.getStorageSync('userInfo') != '' && uni.getStorageSync('userInfo') != undefined) {
							// 已经授权，可以直接调用 getUserInfo 获取头像昵称
							uni.getUserInfo({
								success: (userRes) => {
									uni.getStorage({
										key: 'userInfo',
										success(res) {
											that.bingUser()
											that.avatarUrl = res.data.avatarUrl
											that.hidden = false
											that.$apply()
										}
									})
								}
							})
						} else {
							that.$invoke('Authorization', 'show')
						}
					}
				})
			} else {
				that.$invoke('Authorization', 'show')
			}
			that.$apply()
		},
		//用户授权执行
		bingUser() {
			this.$invoke('Authorization', 'onUser')
		}
	},
}
